<!DOCTYPE html>
<html lang="zh-cn">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  <meta name="renderer" content="webkit">
  <title></title>
  <link rel="stylesheet" href="/Public/Admin/css/pintuer.css">
  <link rel="stylesheet" href="/Public/Admin/css/admin.css">
  <script src="/Public/Admin/js/jquery.js"></script>
  <script src="/Public/Admin/js/pintuer.js"></script>
</head>
<body>
<div class="panel admin-panel margin-top" id="add">
  <div class="panel-head"><strong><span class="icon-pencil-square-o"></span> 添加班级</strong></div>
  <div class="body-content">
    <form method="post" class="form-x" action="/Admin/Classes/ClassesAdd">
      <if condition="$department neq null">
        <div class="form-group">
          <div class="label">
            <label>所属系部：</label>
          </div>
          <div class="field">
            <select name="dep_id" class="input w50">
              <foreach name="department" item="v">
                <option  value="{$v.id}" <if condition="$v['id'] eq $info['dep_id']">selected</if> >{$v.name}</option>
              </foreach>
            </select>
          </div>
        </div>
        <else/>
        <div class="form-group">
          <div class="label">
            <label>所属系部：</label>
          </div>
          <div class="field">
            <input type="text" class="input w50"  name="dep_id"  readonly placeholder="请先去配置所属系部" data-validate="required:请先去配置产品分类" required />
          </div>
        </div>
      </if>
      <div class="form-group">
        <div class="label">
          <label>班级名称：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" name="name" value=""  />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <button class="button bg-main icon-check-square-o" type="submit"> 提交</button>
        </div>
      </div>
    </form>
  </div>
</div>
<div class="panel admin-panel">
  <div class="panel-head"><strong class="icon-reorder"> 产品列表</strong> <a href="" style="float:right; display:none;">添加字段</a></div>
  <div class="padding border-bottom">

    <ul class="search" style="padding-left:10px;">
      <form action="/Admin/Classes/index" method="get">
        <ul class="search" style="padding-left:10px;">
          <li>
            <select name="dep_id" class="input" style="width:250px; line-height:17px;display:inline-block">
              <option  value="0"  >全部</option>
              <foreach name="department" item="v">
                <option  value="{$v.id}"  <if condition="$v['id'] eq $dep_id">selected</if> >
                {$v.name}
                </option>
              </foreach>
            </select>
          </li>
          <li><input type="submit" class="button border-main icon-search" value="搜索"></li>
          <li>
            <button type="button" class="button border-yellow" onclick="window.location.href='/Admin/Product/addProduct'"><span class="icon-plus-square-o"></span> 添加产品</button>
          </li>
        </ul>
      </form>

    </ul>

  </div>
  <table class="table table-hover text-center">
    <tr>
      <th width="100" style=" padding-left:20px;">序号</th>
      <th>班级</th>
      <th>所属系部</th>
      <th>班级人数</th>
      <th>添加时间</th>
      <th width="300px">操作</th>
    </tr>
    <foreach name="lists" item="v">
      <tr>
        <td>{$v.id}</td>
        <td>{$v.name}</td>
        <td>{$v.depName}</td>
        <td>{$v.num}</td>
        <td>{$v.add_time}</td>
        <td><div class="button-group">
          <a class="button border-red" href="javascript:void(0)" onclick="return del({$v.id})"><span class="icon-trash-o"></span> 删除</a>
        </div></td>
      </tr>
    </foreach>
    <tr>
      <td colspan="14">
        <if condition="$lists eq null">
          暂无信息
          <else/>
          <div class="pagelist">
            <a href="/Admin/Classes/index/page/0">首页</a>
            <a href="/Admin/Classes/index/page/{$pages['page']-1}">上一页</a>
            <foreach name="pages.num" item="p">
              <if condition="$p-1 eq $pages['page']">
                <span class="current">{$p}</span>
                <else/>
                <a href="/Admin/Classes/index/page/{$p-1}">{$p}</a>
              </if>
            </foreach>
            <a href="/Admin/Classes/index/page/{$pages['page']+1}">下一页</a>
            <a href="/Admin/Classes/index/page/{$pages['total']}">尾页</a>
          </div>
        </if>
      </td>
    </tr>
  </table>
</div>
<script type="text/javascript">
  function del(id){
    if(confirm("您确定要删除吗?")){
      $.ajax({
        url:"/Admin/Classes/delData",
        type:"get",
        data:{
          'id':id,
          'table':'class'
        },
        success:function(data){
          if(data == 1){
            alert("删除成功");
            location.reload();
          } else if(data == 2) {
            alert("班级下面已有学生注册，无法删除");
            location.reload();
          }
          else alert("删除失败");
        }
      })

    }
  }
</script>

<script>
  $("body").bind("keydown",function(event){
    if (event.keyCode == 116) {
      event.preventDefault(); //阻止默认刷新
      //location.reload();
      //采用location.reload()在火狐下可能会有问题，火狐会保留上一次链接
      location=location;
    }
  })
</script>
</body></html>